package cn.vihub.service.impl;

import cn.vihub.param.ShopBrandParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.vihub.mapper.ShopBrandInfoMapper;
import cn.vihub.pojo.ShopBrandInfo;
import cn.vihub.service.ShopBrandInfoService;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: 秋晚
 * @Date:  2025/7/25 08:41
 * @Description: 
 **/

@Service
@Transactional(rollbackFor = Exception.class)
public class ShopBrandInfoServiceImpl extends ServiceImpl<ShopBrandInfoMapper, ShopBrandInfo> implements ShopBrandInfoService{

    @Autowired
    ShopBrandInfoMapper shopBrandInfoMapper;

    @Value("${minio.imgurl}")
    private String imgurl;
    @Override
    public IPage<ShopBrandInfo> pageShopBrand(ShopBrandParam shopBrandParam) {
        //创建分页对象
        Page<ShopBrandInfo> infoPage = new Page<>(shopBrandParam.getPage(), shopBrandParam.getLimit());


        //处理图片给图片加前缀
        Page<ShopBrandInfo> page = shopBrandInfoMapper.selectPage(infoPage, new LambdaQueryWrapper<ShopBrandInfo>().like(StringUtils.isNotBlank(shopBrandParam.getName()), ShopBrandInfo::getName, shopBrandParam.getName()));
//        for (ShopBrandInfo record : page.getRecords()) {
//            record.setPic(imgurl+record.getPic());
//        }
        //返回查询数据
        return page;
    }
}
